home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / QuickDraw GX / QuickDraw GX Info / QuickDraw GX Interfaces / Interfaces & Libraries / graphics libraries / graphics library.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-30  |  2.1 KB  |  104 lines  |  [TEXT/MPS ]

  1. /* graphics libraries:
  2.     general library routines    
  3.     by Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Oliver Steele, David Van Brink, Chris Yerga
  4.     Copyright 1987 - 1991 Apple Computer, Inc.  All rights reserved.    */
  5.  
  6.     #include <Memory.h>
  7. #include "graphics libraries.h"
  8.  
  9.  
  10. #ifdef MacintoshIncludes
  11. #endif
  12.  
  13.  
  14. /*************/
  15. /* General routines */
  16. /*************/
  17.  
  18. void DisposeShapeAt(gxShape *oldShape)
  19. {
  20.     NilParamReturn(oldShape);
  21.     if (*oldShape) {
  22.         GXDisposeShape(*oldShape);
  23.         *oldShape = nil;
  24.     }
  25. }
  26.  
  27. void DisposeStyleAt(gxStyle   *oldStyle)
  28. {
  29.     NilParamReturn(oldStyle);
  30.     if (*oldStyle) {
  31.         GXDisposeStyle(*oldStyle);
  32.         *oldStyle = nil;
  33.     }
  34. }
  35.  
  36. void DisposeInkAt(gxInk *oldInk)
  37. {
  38.     NilParamReturn(oldInk);
  39.     if (*oldInk) {
  40.         GXDisposeInk(*oldInk);
  41.         *oldInk = nil;
  42.     }
  43. }
  44.  
  45. void DisposeTransformAt(gxTransform *oldTransform)
  46. {
  47.     NilParamReturn(oldTransform);
  48.     if (*oldTransform) {
  49.         GXDisposeTransform(*oldTransform);
  50.         *oldTransform = nil;
  51.     }
  52. }
  53.  
  54.  
  55. /****************/
  56. /* operations on shapes */
  57. /****************/
  58. static void GetSpaceMapping(gxViewPort port, gxViewDevice device, gxMapping *map)
  59. {
  60.     if (port)
  61.         GXGetViewPortGlobalMapping(port, map);
  62.     else
  63.         ResetMapping(map);
  64.  
  65.     if( device ) {
  66.         gxMapping temp;
  67.         MapMapping(map, GXGetViewDeviceMapping(device, &temp));
  68.     }
  69. }
  70.  
  71. void MapShapeToSpace(gxShape source, gxViewPort port, gxViewDevice device)
  72. {
  73.     gxMapping map;
  74.  
  75.     GetSpaceMapping(port, device, &map);
  76.     GXMapShape(source, &map);
  77. }
  78.  
  79. void MapShapeFromSpace(gxShape source, gxViewPort port, gxViewDevice device)
  80. {
  81.     gxMapping map;
  82.  
  83.     GetSpaceMapping(port, device, &map);
  84.     InvertMapping(&map, &map);
  85.     GXMapShape(source, &map);
  86. }
  87.  
  88. void MapPointToSpace(gxPoint *pt, gxViewPort port, gxViewDevice device)
  89. {
  90.     gxMapping map;
  91.  
  92.     GetSpaceMapping(port, device, &map);
  93.     MapPoints(&map, 1, pt);
  94. }
  95.  
  96. void MapPointFromSpace(gxPoint *pt, gxViewPort port, gxViewDevice device)
  97. {
  98.     gxMapping map;
  99.  
  100.     GetSpaceMapping(port, device, &map);
  101.     InvertMapping(&map, &map);
  102.     MapPoints(&map, 1, pt);
  103. }
  104.